/*
public class RandomListNode {
    int label;
    RandomListNode next = null;
    RandomListNode random = null;

    RandomListNode(int label) {
        this.label = label;
    }
}
*/
public class Solution {
        public RandomListNode Clone(RandomListNode pHead)
    {
        if(pHead==null) return pHead;
        RandomListNode pHeadcopy = pHead;
        RandomListNode temp;
        while(pHead!=null){//第一步按照next节点复制链。
            temp = new RandomListNode(pHead.label);
            temp.next = pHead.next;
            pHead.next = temp;
            pHead = temp.next;
        }
        pHead = pHeadcopy;
        while(pHead!=null){//第二步复制链表上的随机节点
            if(pHead.random!=null){
                pHead.next.random = pHead.random.next;
            }
			pHead = pHead.next.next;
        }
        //第三步取01234中的奇数节点。
        pHeadcopy = pHeadcopy.next;
        RandomListNode second = pHeadcopy;
        while(pHeadcopy!=null && pHeadcopy.next!=null){
            pHeadcopy.next = pHeadcopy.next.next;
            pHeadcopy =  pHeadcopy.next;
        }
        return second;
    }
}